// 遍历对象
Object.prototype[Symbol.iterator] = function() {
  const self = this;
  const keys = Object.keys(this);
  let index = 0;
  return {
    next() {
      const key = keys[index];
      const result = {
        value: self[key],
        done: index >= keys.length,
      };
      index++;
      return result;
    },
  };
};

const obj = {
  bar: "bar",
  foo: "foo",
  baz: "baz",
};

for (const item of obj) {
  console.log(item);
}
